package com.lihua.newideas.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lihua.newideas.mapper.UploadMapper;
import com.lihua.newideas.pojo.UploadSystem;
import com.lihua.newideas.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UploadServiceImpl implements UploadService {

    @Autowired
    private UploadMapper uploadMapper;

    @Override
    public void save(UploadSystem file) throws Exception {
        uploadMapper.insert(file);
    }

    @Override
    public PageInfo<UploadSystem> getFileAll(int page, int limit) {
        String orderBy = "id desc"; //排序
        PageHelper.startPage(page, limit,orderBy);
        List<UploadSystem> lists = uploadMapper.getAllFile();
//        System.out.println("业务层：");
//        System.out.println(lists.get(0).toString());
//        PageInfo<UploadSystem> uploadSystemPageInfo = new PageInfo<>(lists);  等于 new PageInfo<>(lists)
        return new PageInfo<>(lists);
    }
}
